﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MySql.Data;
using MySql.Data.MySqlClient;

namespace DataAccess
{
    public class Query
    {
        private string _roomID;
        private string _roomType;
        private double _roomPrice;
        private string _roomstatus;
        #region
        public string roomID
        {
            get { return _roomID; }
            set { _roomID = value; }
        }

        public string roomType
        {
            get { return _roomType; }
            set { _roomType = value; }
        }

        public double roomPrice
        {
            get { return _roomPrice; }
            set { _roomPrice = value; }
        }

        public string roomStatus
        {
            get { return _roomstatus; }
            set { _roomstatus = value; }
        }
        #endregion

        public static DataSet Queryof(string methods, string input)
        {
            if (methods.Equals("Empty") && input.Equals(""))
            {
                string sql = "select * from roomstatus where roomStatus = 'Empty'";
                MySqlParameter ps = new MySqlParameter("@par1", input);
                DataSet ds = MySqlHelper.GetDataSet(MySqlHelper.Conn, CommandType.Text, sql, ps);
                return ds;
            }
            else if(methods.Equals("Full") && input.Equals(""))
            {
                string sql = "select * from roomstatus where roomStatus = 'Full' ";
                MySqlParameter ps = new MySqlParameter("@par1", input);
                DataSet ds = MySqlHelper.GetDataSet(MySqlHelper.Conn, CommandType.Text, sql, ps);
                return ds;
            }
            else if(methods.Equals("Person") && input.Equals(""))
            {
                string sql = "select * from userinfo ";
                MySqlParameter ps = new MySqlParameter("@par1", input);
                DataSet ds = MySqlHelper.GetDataSet(MySqlHelper.Conn, CommandType.Text, sql, ps);
                return ds;
            }
            else
            {
                string sql = "select * from roomstatus where " + methods + "=@par1";
                MySqlParameter ps = new MySqlParameter("@par1", input);
                DataSet ds = MySqlHelper.GetDataSet(MySqlHelper.Conn, CommandType.Text, sql, ps);
                return ds;
            }

        }

    }
}
